<template>
  <div class="tablec">
    <div>
      <el-table
        class="eltable"
        :data="
          search().slice((currentPage - 1) * pagesize, currentPage * pagesize)
        "
        stripe
        border
      >
        <el-table-column prop="date" label="文件名">
        </el-table-column>
        <el-table-column prop="name" label="大小" width="250">
        </el-table-column>
        <el-table-column prop="time" label="创建日期">
        </el-table-column>
        <el-table-column label="操作" width="75"
          ><el-button type="primary" icon="el-icon-download" circle></el-button
        ></el-table-column>
      </el-table>

      <el-row style="width:80%;margin: 0 auto;margin-top: 25px;">
        <el-col>
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[5, 10, 20, 40]"
            :page-size="pagesize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="search().length"
          >
          </el-pagination>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      keyword: "",
      fieList: [],
      paths: [],
      pagesize: 10,
      currentPage: 1,
    };
  },
  computed: {},
  methods: {
    search() {
      if (this.keyword.trim == "") {
        return this.fieList;
      }
      let result = this.fieList.filter((element) => {
        return element.dname.includes(this.keyword);
      });
      return result;
    },
    delFile(index) {
      this.fieList.splice(index, 1);
    },
    // 初始页currentPage、初始每页数据数pagesize和数据data
    handleSizeChange(size) {
      this.pagesize = size;
      //  console.log(this.pagesize)  //每页下拉显示数据
    },
    handleCurrentChange(currentPage) {
      this.currentPage = currentPage;
      // console.log(this.currentPage)  //点击第几页
    },
  },
};
</script>

<style>
.tablec {
  width: 100%;
  min-width: 1000px;
}
.eltable {
  width: 80%;
  margin: 0 auto;
}
</style>